package com.hmily.dubbo.consumer.sync;

import com.hmily.dubbo.api.LongTimeQueryFacade;
import com.hmily.dubbo.api.UserQueryFacade;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;

/**
 * <h1>负载均衡策略设置, 启动类。</h1>
 *
 * @author hmilyylimh
 *         ^_^
 * @version 0.0.1
 *         ^_^
 * @date 2021-10-21
 *
 */
public class XmlLoadBalanceConsumerApplication {

    public static void main(String[] args) throws IOException {
        String configPath = "classpath*:META-INF/spring/loadbalance_consumer.xml";
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(configPath);
        ctx.refresh();

        // 接口调用
        UserQueryFacade userQueryFacade = ctx.getBean(UserQueryFacade.class);
        for (int i = 0; i < 18; i++) {
            System.out.println("第 " + i + " 次调用: " + userQueryFacade.queryUser("hmily"));
        }


        // 阻塞等待
        System.in.read();
    }
}
